<?php
	session_start();
	$func = $_POST["func"];
	switch($func) {
		case "fetch":
			require "class.post.php";
			print Post::fetch($_POST["title"]);
			break;
		case "recent":
			require "class.post.php";
			print Post::recent($_POST["lower"], $_POST["higher"]);
			break;
		case "search":
			require "class.post.php";
			print Post::search($_POST["title"]);
			break;
		case "history":
			require "class.post.php";
			print Post::history($_POST["title"]);
			break;
		case "history_view":
			require "class.post.php";
			print Post::history_view($_POST["id"]);
			break;
		case "undo":
			require "class.post.php";
			if ($_SESSION["mnwiki_user"] != NULL)
				print Post::undo($_POST["title"], $_POST["id"], $_SESSION["mnwiki_user"]);
			break;
		case "children":
			require "class.post.php";
			print Post::children($_POST["title"]);
			break;
		case "create":
			require "class.post.php";
			if ($_SESSION["mnwiki_user"] != NULL)
				print Post::create($_SESSION["mnwiki_user"], $_POST["title"], $_POST["content"]);
			break;
		case "edit":
			require "class.post.php";
			if ($_SESSION["mnwiki_user"] != NULL)
				print Post::edit($_SESSION["mnwiki_user"], $_POST["title"], $_POST["content"]);
			break;
		default:
			break;
	}
?>
